package com.yanchi.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * 自定义网关全局过滤器
 * @author yanchi
 */
@Configuration
public class CustomGlobalFilter implements GlobalFilter, Ordered {

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("过滤器之前！！！");
        Mono<Void> filter = chain.filter(exchange);
        System.out.println("过滤器之后！！！");
        return filter;
    }

    @Override
    public int getOrder() {
        return -1;
    }
}
